package pat.toplevel;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public interface GreedySnake {
    /**
     * 贪吃蛇。获得最多的食物
     * @param graph         初始化了障碍的图
     * @return              最大可得到值，及其得到次数
     */
    int[] task1(char[][] graph);

    /**
     * 贪吃蛇。获得最多的食物，允许将一个障碍物变成食物
     * @param graph         初始化了障碍的图
     * @return              最大可得到值，及其得到次数
     */
    int[] task2(char[][] graph);
}

class Main{
    static final int[][] dirs = new int[][]{{-1,0},{1,0},{0,1},{0,-1}};
    static final char EDGE = '#';
    static final char OBSTACLE = '@';
    static final char FOOD = '.';
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        int K = input.nextInt();
        char[][] graph = new char[N][N];
        for (int i = 0; i < N; i++) {
            Arrays.fill(graph[i], FOOD);
        }
        for (int i = 0; i < N; i++) {
            graph[0][i] = EDGE;
        }
        for (int i = N - 1; i < N; i++) {
            graph[N - 1][i] = EDGE;
        }
        for (int i = 0; i < N; i++) {
            graph[i][0] = EDGE;
        }
        for (int i = 0; i < N; i++) {
            graph[N - 1][i] = EDGE;
        }
        for (int i = 0; i < K; i++) {
            int x = input.nextInt();
            int y = input.nextInt();
            graph[x][y] = OBSTACLE;
        }

        int[] ans1 = new GreedySnakeImpl1().task1(graph);
        System.out.println(ans1[0] + " " + ans1[1]);

        int[] ans2 = new GreedySnakeImpl1().task2(graph);
        if(ans2.length == 1){
            System.out.println( -1);
        }else {
            System.out.println(ans2[0] + " " + ans2[1]);
        }
    }
}

class GreedySnakeImpl1 implements  GreedySnake{
    static final int[][] dirs = new int[][]{{-1,0},{1,0},{0,1},{0,-1}};
    static final char EDGE = '#';
    static final char OBSTACLE = '@';
    static final char FOOD = '.';
    @Override
    public int[] task1(char[][] graph) {
        Map<Integer, Integer> foodsFrequencies = new HashMap<>();
        int n = graph.length;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if(graph[i][j] == FOOD){
                    int obtainFoods = dfs(i,j);
                    foodsFrequencies.put(obtainFoods, foodsFrequencies.getOrDefault(obtainFoods, 0) + 1);
                }
            }
        }
        int maxFoods = 0, maxFreq = 0;
        for(Map.Entry<Integer, Integer> entry : foodsFrequencies.entrySet()){
            int key = entry.getKey();
            int val = entry.getValue();
            if(maxFoods < key){
                maxFoods = key;
                maxFreq = val;
            }
        }
        return new int[]{maxFoods, maxFreq};
    }
    private int dfs(int i,int j){
        return 0;
    }
    private void trackBack(){

    }

    @Override
    public int[] task2(char[][] graph) {
        return new int[0];
    }
}
